
# 简答题
# 一、
def sum(n):
    sum=0
    for i in range(1,n+1):
        sum += (-1)**(i-1)/i
    return sum
print(sum(5))

# 二、
import pymysql
username=[{'name': '鬲小杰', 'no ': 'WN001'}, {'name': '刘小畅', 'no ': 'WN002'}, {'name': '姜小泊', 'no ': 'WN003'}]
connect_info= {'host': '192.168.13.54', 'port': 3306, 'user': 'root', 'password': 'root123', 'database': 'school2', 'charset': 'utf8'}
cnn=pymysql.connect(**connect_info)
cur=cnn.cursor(pymysql.cursors.DictCursor)
sql=f"""SELECT student.sno as no,student.sname as name, if( MIN(score.sc)>=60,"合格","不合格") as check_result FROM
student LEFT JOIN  score on student.sno=score.sno where student.sno in {str(tuple([i['no '] for i in username]))} group by no,name;"""
print(sql)
cur.execute(sql)
print(cur.fetchall())
cur.close()
cnn.close()

